/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var swapPairs = function (head) {
  if (!head || !head.next) return head

  //t1、t2保存head的后面两个节点
  let t1 = head.next
  let t2 = head.next.next


  t1.next = head//交换
  head.next = swapPairs(t2)//递归处理 t2 后续部分
  return t1//返回新的头节点
};